package com.example.hospitalmanagement.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.hospitalmanagement.R
import com.example.hospitalmanagement.adapter.ServiceFragmentAdapter
import com.example.hospitalmanagement.bean.DiagnosisAndTreatmentItem
import com.example.hospitalmanagement.bean.NameMassage
import com.example.hospitalmanagement.databinding.FragmentIndividualBinding
import kotlinx.android.synthetic.main.fragment_individual.*

/**
 * 个人中心页面Fragment
 */
class IndividualFragment : Fragment() {
    private lateinit var fragmentIndividual: FragmentIndividualBinding

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        fragmentIndividual = DataBindingUtil.inflate(
            inflater, R.layout.fragment_individual, container, false
        )
        return fragmentIndividual.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
    }

    private fun initView() {
        patients_entance_item.layoutManager = LinearLayoutManager(requireActivity())
        var datalist: MutableList<NameMassage> = mutableListOf(
            NameMassage(
                "306003545187",
                "371428********3016",
                "旋风小子"
            )
        )
        var adapter = IndividualFragmentAdapter(requireActivity())
        adapter.dataList = datalist
        patients_entance_item.adapter = adapter

        payment_service_item.layoutManager = GridLayoutManager(requireActivity(), 4)
        var datalist01: MutableList<DiagnosisAndTreatmentItem> = mutableListOf(
            DiagnosisAndTreatmentItem(
                R.mipmap.gain_number_pay,
                "取号服务"
            )
        )
        var adapter01 = ServiceFragmentAdapter(requireActivity())
        adapter01.dataList = datalist01
        payment_service_item.adapter = adapter01

        integrated_query_item.layoutManager = GridLayoutManager(requireActivity(), 4)
        var datalist02: MutableList<DiagnosisAndTreatmentItem> = mutableListOf(
            DiagnosisAndTreatmentItem(
                R.mipmap.checkout_report,
                "检验报告单"
            ), DiagnosisAndTreatmentItem(
                R.mipmap.inspect_report,
                "检查报告单"
            ), DiagnosisAndTreatmentItem(
                R.mipmap.service_cost,
                "门诊花费"
            ), DiagnosisAndTreatmentItem(
                R.mipmap.daily_list,
                "每日清单"
            )

        )
        var adapter02 = ServiceFragmentAdapter(requireActivity())
        adapter02.dataList = datalist02
        integrated_query_item.adapter = adapter02


        handy_service_for_the_public_item.layoutManager = GridLayoutManager(requireActivity(), 4)
        var datalist03: MutableList<DiagnosisAndTreatmentItem> = mutableListOf(
            DiagnosisAndTreatmentItem(
                R.mipmap.capatry_see_a_docater,
                "智能候诊"
            ), DiagnosisAndTreatmentItem(
                R.mipmap.eat_serve,
                "就餐服务"
            ), DiagnosisAndTreatmentItem(
                R.mipmap.eat_serve,
                "就餐服务（测试）"
            ), DiagnosisAndTreatmentItem(
                R.mipmap.medice_cube,
                "药立方"
            )
        )
        var adapter03 = ServiceFragmentAdapter(requireActivity())
        adapter03.dataList = datalist03
        handy_service_for_the_public_item.adapter = adapter03
    }
}